package com.boomsecret.juc.atomic;

import java.util.concurrent.atomic.LongAdder;

/**
 * @author wangjinliang on 2019/1/17.
 */
public class LongAdderDemo {

    public static void main(String[] args) {
        LongAdder longAdder = new LongAdder();
        System.out.println(longAdder.sum());

        System.out.println("-------------");
        longAdder.add(2L);
        System.out.println(longAdder.sum());

        System.out.println("-------------");
        longAdder.increment();
        System.out.println(longAdder.sum());

        System.out.println("-------------");
        longAdder.decrement();
        System.out.println(longAdder.sum());

        System.out.println("-------------");
        // 没有线程更新的时候
        longAdder.reset();
        System.out.println(longAdder.sum());
    }
}
